package net.bwie.jtp.app.udf;

import ch.hsr.geohash.GeoHash;
import org.apache.hadoop.hive.ql.exec.Description;
import org.apache.hadoop.hive.ql.exec.UDF;
@Description(
        name="convert_geohash",
        value="_FUNC_(latitude, longitude, precision) - return a geohash code"
)

public class ConvertGeoHash extends UDF {
    public String evaluate(double latitude,double longitude,int precision){
        String geoHash = GeoHash.geoHashStringWithCharacterPrecision(latitude, longitude, precision);

        return geoHash;
    }

    public static void main(String[] args) {
        System.out.println(
                new ConvertGeoHash().evaluate(35.4684,119.3627,6)
        );
    }
}
